<?php
namespace Game\Action\Character;

use Game\Entity\Person;

/**
 * Description of ShowActionsAction
 *
 * @author pahhan
 */
class ShowActionsAction extends \Game\Action\AbstractAction
{
    public function getCode()
    {
        return 'cmd';
    }

    public function getDescription()
    {
        return 'Заценить варианты';
    }

    public function execute($object)
    {
        $owner = $this->getOwner();
        $owner instanceof Person;
        $env = $owner->getEnvironment()->init();
        $env->bindActionsToCharacter($owner);
        $msg = '';
        foreach( $owner->getActions() as $key => $action )
        {
            $msg.= sprintf('%s - %s', $key, $action->getDescription()).PHP_EOL;
        }
        $this->_message = $msg;
    }

    public function getResultArray()
    {
        return array('message' => $this->getMessage());
    }
}